#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
typedef struct
{
    int st,ed;
    int v;
}Tsegment;

bool operator < (Tsegment a, Tsegment b)
{
    return a.st < b.st;
}

Tsegment seg[1100];
int n;
int i;
int ans[1100];

bool init()
{
    if (scanf("%d", &n)==EOF) return false;
    for (i=0; i<n; ++i)
        scanf("%d%d%d", &seg[i].st, &seg[i].ed, &seg[i].v);
    return true;
}    
void deal()
{
    int maxans=0;
    sort(seg, seg+n);
    int i, j;
    for (i=0; i<n; ++i)
    {
        ans[i] = seg[i].v;
        for (j=0; j<i; ++j)
            if (seg[i].st > seg[j].ed && ans[i]<ans[j]+seg[i].v) 
                  ans[i] = ans[j]+seg[i].v;      
        if (maxans < ans[i]) maxans = ans[i];
    }    
    printf("%d\n", maxans);
}    

int main()
{
    while (init())
    {
         deal();       
    }        
    return 0;    
}    

